package com.example.tourism.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class OrderNumberGenerator {
    public static String generateOrderNumber() {
        long timestamp = System.currentTimeMillis();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        String formattedTimestamp = dateFormat.format(new Date(timestamp));
        
        int random = (int) (Math.random() * 10000);
        String prefix = formattedTimestamp + random;
        
        int sum = 0;
        for (char c : prefix.toCharArray()) {
            sum += (int) c;
        }
        int checksum = sum % 10;
        
        String orderNumber = prefix + checksum;
        return orderNumber;
    }
}